﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:vm="clr-namespace:Lithnet.Transforms.Presentation"
                    >
    <Style TargetType="{x:Type TreeViewItem}"
           BasedOn="{StaticResource {x:Type TreeViewItem}}">
        <Setter Property="IsSelected"
                Value="{Binding IsSelected, Mode=OneWayToSource}" />
        <Setter Property="IsExpanded"
                Value="{Binding IsExpanded, Mode=TwoWay}" />
    </Style>

    <HierarchicalDataTemplate ItemsSource="{Binding Path=.}"
                              DataType="{x:Type vm:TransformCollectionViewModel}">
        <StackPanel>
            <StackPanel Orientation="Horizontal"
                        Margin="2">
                <StackPanel.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="Add Transform..."
                                  Command="{Binding Commands.AddTransform}" />
                        <Separator />
                        <MenuItem Header="Paste"
                                  Command="{Binding Commands.Paste}" />
                    </ContextMenu>
                </StackPanel.ContextMenu>
                <Image Source="{Binding DisplayIcon}"
                       Width="16"
                       Height="16"
                       SnapsToDevicePixels="True" />
                <TextBlock Text="{Binding DisplayName}"
                           Margin="5,0" />
            </StackPanel>

            <Control Template="{StaticResource RedUnderlineError}"
                     Visibility="{Binding HasErrors, Converter={StaticResource BooleanToVisibilityConverter}}" />

        </StackPanel>
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate DataType="{x:Type vm:TransformViewModel}"
                             >
        <StackPanel>
            <StackPanel Orientation="Horizontal"
                        Margin="2">
                <StackPanel.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="Delete Transform..."
                                  Command="{Binding Commands.DeleteTransform}" />
                        <Separator />
                        <MenuItem Header="Cut"
                                  Command="{Binding Commands.Cut}" />
                        <MenuItem Header="Copy"
                                  Command="{Binding Commands.Copy}" />
                    </ContextMenu>
                </StackPanel.ContextMenu>
                <Image Source="{Binding DisplayIcon}"
                       Width="16"
                       Height="16"
                       SnapsToDevicePixels="True" />
                <TextBlock Text="{Binding DisplayName}"
                           Margin="5,0">
                </TextBlock>
            </StackPanel>

            <Control Template="{StaticResource RedUnderlineError}"
                     Visibility="{Binding HasErrors, Converter={StaticResource BooleanToVisibilityConverter}}" />

        </StackPanel>
    </HierarchicalDataTemplate>
</ResourceDictionary>